export function getStyle(style, filter) {
  const needUnit = [
    'width',
    'height',
    'top',
    'left',
    'bottom',
    'paddingTop',
    'paddingBottom',
    'paddingLeft',
    'paddingRight',
    'fontSize'
    // 'lineHeight'
  ];

  const result = {};
  filter = filter || Object.keys(style);
  // flag: false 取filter指定key的值
  filter.forEach((attr) => {
    if (needUnit.includes(attr) && typeof style[attr] === 'number') {
      if ((attr === 'left' || attr === 'top') && style.position === 'relative') return;
      result[attr] = `${style[attr]}px`;
    } else {
      result[attr] = style[attr];
    }
  });

  return result;
}
